class App {
    constructor(public readonly options: Options) {
        this.initError();
    }

    private readonly initError = () => {
        const { onAppError } = this.options;
        console.log(onAppError);
    }

    public readonly start = async (opt: StartOpt) => {
        const { preRender, postRender } = this.options;
        preRender && await preRender(this);
        (await import('react-dom')).render(opt.rootComponent, opt.rootDom);
        postRender && await postRender(this);
    }
}

type Options = {
    onAppError?(err: Error): any;
    preRender?(app: App): dp.PromiseOrSelf<void>;
    postRender?(app: App): dp.PromiseOrSelf<void>;
};

type StartOpt = {
    rootComponent: React.ReactElement;
    rootDom: Element | null;
};

const app = new App({});

export default app;
